/**
 * 郭楠project
 * com.gn.controller
 * CommentController.java
 * 创建人:TonyGuo 
 * 时间：2016年12月14日-下午9:57:19 
 * 2016Tm公司-版权所有
 */
package com.gn.controller;

import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.gn.entity.AdminUser;
import com.gn.entity.Comment;
import com.gn.entity.CommentZanPaizhuan;
import com.gn.entity.R;
import com.gn.service.CommentService;
import com.gn.service.CommentZanPaizhuanService;
import com.gn.util.CommonUtils;

/**
 * 
 * CommentController
 * 创建人:TonyGuo
 * 时间：2016年12月14日-下午9:57:19 
 * @version 1.0.0
 * 
 */
@RestController
@RequestMapping("/comment")
public class CommentZanPaizhuanController {
	Logger logger = LoggerFactory.getLogger(CommentZanPaizhuanController.class);
	@Resource
	private CommentZanPaizhuanService commentZanPaizhuanService;
	
	@RequestMapping(value="/zanorzhuan.save")
	public R saveCommentZanPaizhuan(HttpServletRequest req,CommentZanPaizhuan commentZanPaizhuan){
		commentZanPaizhuanService.addUserCommentZanOrPaizhuan(commentZanPaizhuan);
		return R.ok();
	}
	

	/**
	 * 【拍砖】
	 * @param paizhuanCount 拍砖数
	 * @param id 该评论的id
	 */
	@RequestMapping(value="/user.zanorzhuan.status.get")
	public List<CommentZanPaizhuan> findUserCommentZanPaizhuan(HttpServletRequest req,String cid) {
		Map<String,Object> map=new HashMap<>();
		AdminUser user=(AdminUser)req.getSession().getAttribute("curr_user");
		map.put("uid", user.getUserid());
		map.put("cid", cid);
		return commentZanPaizhuanService.findUserCommentZanOrPaizhuan(map);
	}

}
